import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css'   // 样式的初始设置

import Element from 'element-ui'
import './styles/element-variables.scss'   // 全局组件样式
import '@/styles/index.scss'   // 全局样式

import App from './App'
// import router from './router'
import store from './store'
import router from './router'

//-----------------------------
import 'jquery'

import i18n from './lang' // 国际化
import './icons' // icon
import './permission' // 权限控制
import './utils/error-log' // 错误日志

import * as filters from './filters' // global filters

import { sha256 } from 'js-sha256'
import visibility from 'vue-visibility-change'
// datav
import dataV from '@jiaminghi/data-view'

Vue.prototype.$sha256 = sha256
Vue.use(visibility)
Vue.use(dataV)

if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
